<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="../include/laypublic.jsp" %>
<!DOCTYPE html>
<html>
<head>
</head>
<title>风险总览</title>
<style type="text/css">
    .layui-form-select dl {
        max-height: 150px;
    / / 原值为300，调节高度建议为50的倍数

    }

    .layui-form-label {
        width: 130px;

    }
</style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <!-- 查询区域  -->
        <div id="query-form" class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">风险来源</label>
                    <div class="layui-input-inline">
                        <select name="riskStage">
                            <c:if test="${not empty proStage }">
                                <c:forEach items="${proStage}" var="list">
                                    <option value="${list.node}">${list.nodeName }</option>
                                </c:forEach>
                            </c:if>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">创建日期</label>
                    <div class="layui-input-inline">
                        <input type="date" class="layui-input" id="yxch-laydate-dates" name="addTime" placeholder="年/月/日">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">风险等级</label>
                    <div class="layui-input-inline">
                        <select name="riskLevel">
                            <option value="1">低</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-inline">
                        <select name="status">
                            <option value="0">未销项</option>
                        </select>
                    </div>
                </div>
                <shiro:hasPermission name="LIST_DISCLOSE_PRO">
                    <div class="layui-inline">
                        <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="LAY-disclosePro-search">
                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
                        </button>
                        <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="LAY-user-back-reset">
                            <i class="layui-icon layui-icon-fonts-clear  layuiadmin-button-btn"></i>重置
                        </button>
                    </div>
                </shiro:hasPermission>
            </div>
        </div>
        <!-- 按钮区域  -->
        <div class="layui-card-body">

            <!-- 数据表单 -->
            <div class="layui-tab layui-tab-brief" lay-filter="component-tabs-brief">
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <table id="LAY-disclosePro-create-manage" lay-filter="LAY-disclosePro-create-manage"></table>
                    </div>
                    <div class="layui-tab-item">
                        <table id="LAY-disclosePro-wait-manage" lay-filter="LAY-disclosePro-wait-manage"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    var proCode = "${proCode}"
    layui.config({
        base: '${ctx}/resources/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'set', 'transfer', 'laydate'], function(){
        var $ = layui.$
            ,form = layui.form
            ,table = layui.table
            ,element = layui.element
            ,laydate = layui.laydate;
        //tab重新渲染宽度
        element.on('tab(component-tabs-brief)', function(obj){
            $(window).resize();
        });

        //日期
        laydate.render({
            elem: '#yxch-laydate-dates'

        });


        // 正则校验
        form.verify({
            //验证汉字
            CHS: [
                /^[\u0391-\uFFE5]+$/
                ,'只能输入汉字'
            ],
            //大于0的正整数
            intNumber:[
                /^[1-9]\d*$/
                ,'请输入正确的数字'
            ]
        });
        // 表单
        table.render({
            elem: '#LAY-disclosePro-create-manage'
            ,url: basePath + '/projectRisk/queryDataByLowRisk?proCode='+proCode //请求数据接口
            ,cols: [[
                {type: 'checkbox', fixed: 'left'}
                ,{field: 'riskDesc', title: '风险描述', width: 145}
                ,{field: 'riskStageName', title: '风险来源', width: 165}
                ,{field: 'addTime', title: '创建日期', width: 280,templet: function(d){
                        return layui.util.toDateString(d.addTime,"yyyy-MM-dd");
                    }}
                ,{field: 'riskLevel', title: '风险等级', width: 120, templet: function(d){
                        if(d.riskLevel == '1'){
                            return '低';
                        }else if(d.riskLevel == '2'){
                            return '中';
                        }else if(d.riskLevel == '3'){
                            return '高';
                        }
                    }}
                ,{field: 'solveWay', title: '处理策略', width: 155, templet: function(d){
                        if(d.solveWay == '0'){
                            return '避免';
                        }else if(d.solveWay == '1'){
                            return '减少';
                        }
                    }}
                ,{field: 'latestProgress', title: '最新进展', width: 155}
                ,{field: 'status', title: '状态', width: 103, fixed: 'right', templet: function(d){
                        if(d.status == '0'){
                            return '未销项';
                        }else if(d.status == '1'){
                            return '已销项';
                        }
                    }
                }
                ,{title: '操作', width: 230, align:'center', fixed: 'right', templet: function(d){
                        var optStr ="";
                        <shiro:hasPermission name="VIEW_DISCLOSE_PRO">
                        optStr += '<a class="layui-btn layui-btn-xs" lay-event="view"><i class="layui-icon layui-icon-form"></i>详情</a>';
                        </shiro:hasPermission>
                        if(d.processStatus == '10'){
                            <shiro:hasPermission name="COPY_DISCLOSE_PRO">
                            optStr += '<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="copy"><i class="layui-icon layui-icon-release"></i>复制单据</a>';
                            </shiro:hasPermission>
                            optStr += '<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>';
                        }
                        return optStr;
                    }
                }
            ]]
            ,page: true
            ,limit: 10
        });

        <shiro:hasPermission name="LIST_DISCLOSE_PRO">
        //监听搜索
        form.on('submit(LAY-disclosePro-search)', function(data){
            console.log(11111)
            var tabId = $(".layui-tab-title .layui-this").attr("lay-id");
            //执行重载
            table.reload('LAY-disclosePro-create-manage', {page: {curr: 1},
                where: trimData(data)
            });
            // var tabId = $(".layui-tab-title .layui-this").attr("lay-id");
            // if(tabId == 'create'){
            //     //执行重载
            //     table.reload('LAY-disclosePro-create-manage', {page: {curr: 1},
            //         where: trimData(data)
            //     });
            // }else{
            //     //执行重载
            //     table.reload('LAY-disclosePro-wait-manage', {page: {curr: 1},
            //         where: trimData(data)
            //     });
            // }
        });
        //重置清空
        form.on('submit(LAY-user-back-reset)', function(data){
            reset_form('query-form');
            //额外处理select
            $("#query-form-state").val('');
            form.render();
        });
        </shiro:hasPermission>

        // 监听操作列
        table.on('tool(LAY-disclosePro-create-manage)', function(obj){
            var data = obj.data;
            if(obj.event === 'view'){//查看详情
                parent.layui.index.openTabsPage(basePath + '/riskOverview/toDealOrDetail?id='+data.id,'风险总览 > 详情');
            }else if(obj.event === 'copy'){//复制单据
                parent.layui.index.openTabsPage(basePath + '/disclosePro/toCopy?id='+data.id,'交底 > 复制单据');
            }else if(obj.event === 'del'){//删除
                layer.confirm('确定要删除？',{icon:3, title :'提示'}, function(index){
                    $.ajax({
                        type : 'post',
                        url : basePath + '/flowProcess/logicDel',
                        data : {
                            "processId" :data.processId
                        },//数据，这里使用的是Json格式进行传输
                        success:function(result){
                            if(result){
                                table.reload('LAY-disclosePro-create-manage'); //数据刷新
                                layer.close(index); //关闭弹层
                            }else{
                                layer.msg('数据通信异常~',{icon: 0});
                            }
                        }
                    });
                })
            }
        });

        // 监听操作列
        table.on('tool(LAY-disclosePro-wait-manage)', function(obj){
            var data = obj.data;
            if(obj.event === 'view'){
                parent.layui.index.openTabsPage(basePath + '/disclosePro/toDealOrDetail?id='+data.id,'交底 > 详情');
            }else if(obj.event === 'toDispatch'){
                parent.layui.index.openTabsPage(basePath + '/flowProcess/toDispatch?processId='+data.processId, '交底 '+ ' > 审批');
            }
        });

        // 按钮事件
        var active = {
            add: function(){
                parent.layui.index.openTabsPage(basePath + '/disclosePro/add','交底 > 新建');
            }
        }
        // data-type事件
        $('.layui-btn.layuiadmin-btn-admin').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });

    //导出excel
    function exportList() {
        layer.msg("暂未上线，敬请期待~",{icon: 1});
        /*var $ = layui.$;
        var params = "?proCode=";
        params += $('#queryProCode').val().trim();
        params += "&startDate=";
        params += $('#sent-laydate-start').val().trim();
        params += "&endDate=";
        params += $('#sent-laydate-end').val().trim();
        params += "&customerName=";
        params += $('#queryCustomerName').val().trim();
        params += "&mobile=";
        params += $('#queryMobile').val().trim();
        params += "&provinceName=";
        params += $('#queryProvinceName').val().trim();
        params += "&cityName=";
        params += $('#queryCityName').val().trim();
        params += "&state=";
        params += $('#queryState').val().trim();
        window.location.href = "${ctx}/disclosePro/exportToExcel"+params;*/
    }
</script>
</body>
</html>
